package com.ephra.dao.servlet.news;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ephra.commons.JsonUtils;
import com.ephra.dao.factory.Factory;

public class Ready extends HttpServlet{
	
	public void doGet(HttpServletRequest request,HttpServletResponse response) throws IOException,ServletException {
		response.setContentType("text/json;charset=UTF-8");
	    response.setCharacterEncoding("UTF-8");
	    PrintWriter out=response.getWriter();

		String str ="{\"data\":\"ERROR\"}";
		try {
			System.out.println(Factory.getNews().ready());
			if(!Factory.getNews().ready().isEmpty()){
				str ="{\"data\":\"SUCCESS\"}";
			}
			out.println(str);
			System.out.println(str);
			out.flush();
			out.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException {
		this.doGet(request, response);
	}
}
